package com.gy.hsim.bservice.message.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.gy.hsim.bservice.framework.mapper.MessageMapper;
import com.gy.hsim.bservice.message.bean.Message;
import com.gy.hsim.bservice.message.bean.MessageSetting;
import com.gy.hsim.bservice.message.service.MessageService;

/**
 * @ClassName: messageServiceImpl
 * @Description: 信息业务服务实现类
 * @author Lee
 * @date 2015-11-10 上午09:37:19
 */
@Service("messageService")
public class MessageServiceImpl implements MessageService{

	@Autowired
	private MessageMapper messageMapper;
	
	@Override
	public List<Message> queryMessageRecordList(Message message) throws Exception {
		// TODO Auto-generated method stub
		List<Message> messageList = new ArrayList<Message>();
		messageList = messageMapper.queryMessageRecordList(message);
		return messageList;
	}

	@Override
	public int queryMessageRecordListCount(Message message) throws Exception {
		// TODO Auto-generated method stub
		int messageRecordListCount = 0;
		messageRecordListCount = messageMapper.queryMessageRecordListCount(message);
		return messageRecordListCount;
	}

	@Override
	public List<Message> queryMessageRecordTotalList(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		List<Message> messageList = new ArrayList<Message>();
		messageList = messageMapper.queryMessageRecordTotalList(message);
		return messageList;
	}

	@Override
	public int queryMessageRecordTotalListCount(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		int messageRecordListCount = 0;
		messageRecordListCount = messageMapper.queryMessageRecordTotalListCount(message);
		return messageRecordListCount;
	}

	@Override
	public List<Message> queryPushMessageRecordList(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		List<Message> messageList = new ArrayList<Message>();
		messageList = messageMapper.queryPushMessageRecordList(message);
		return messageList;
	}

	@Override
	public int queryPushMessageRecordListCount(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		int messageRecordListCount = 0;
		messageRecordListCount = messageMapper.queryPushMessageRecordListCount(message);
		return messageRecordListCount;
	}

	@Override
	public List<Message> queryPushMessageRecordTotalList(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		List<Message> messageList = new ArrayList<Message>();
		messageList = messageMapper.queryPushMessageRecordTotalList(message);
		return messageList;
	}

	@Override
	public int queryPushMessageRecordTotalListCount(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		int messageRecordListCount = 0;
		messageRecordListCount = messageMapper.queryPushMessageRecordTotalListCount(message);
		return messageRecordListCount;
	}

	@Override
	public int messageSetting(MessageSetting messageSetting) throws Exception {
		// TODO Auto-generated method stub
		int successCode = 0;
		int userSettingRows = messageMapper.queryMessageSettingList(messageSetting).size();
		if(userSettingRows > 0 ){
			messageMapper.updateMessageSetting(messageSetting);
		} else {
			messageMapper.addMessageSetting(messageSetting);
		}
		return successCode;
	}

	@Override
	public List<MessageSetting> queryMessageSettingList(
			MessageSetting messageSetting) throws Exception {
		// TODO Auto-generated method stub
		List<MessageSetting> messageSettingList = new ArrayList<MessageSetting>();
		messageSettingList = messageMapper.queryMessageSettingList(messageSetting);
		return messageSettingList;
	}

	@Override
	public List<Message> queryGroupMessageList(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		List<Message> messageList = new ArrayList<Message>();
		messageList = messageMapper.queryGroupMessageList(message);
		return messageList;
	}

	@Override
	public int queryGroupMessageListCount(Message message) throws Exception {
		// TODO Auto-generated method stub
		int messageRecordListCount = 0;
		messageRecordListCount = messageMapper.queryGroupMessageListCount(message);
		return messageRecordListCount;
	}

	@Override
	public List<Message> queryOperRecentContactsMsgList(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		List<Message> messageList = new ArrayList<Message>();
		messageList = messageMapper.queryOperRecentContactsMsgList(message);
		return messageList;
	}

	@Override
	public List<Message> queryConsumerRecentContactsMsgList(Message message)
			throws Exception {
		List<Message> messageList = new ArrayList<Message>();
		messageList = messageMapper.queryConsumerRecentContactsMsgList(message);
		return messageList;
	}

	@Override
	public int queryOperRecentContactsMsgListCount(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		int count = 0;
		count = messageMapper.queryOperRecentContactsMsgListCount(message);
		return count;
	}

	@Override
	public int queryConsumerRecentContactsMsgListCount(Message message)
			throws Exception {
		// TODO Auto-generated method stub
		int count = 0;
		count = messageMapper.queryConsumerRecentContactsMsgListCount(message);
		return count;
	}
	 
}
